﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;

// 模拟帧 FE 00 4D 04 49
namespace LRSystem
{
    public class LRRfModuleSetPayloadLength: ISendPacket
    {
        public byte PayloadLength { get; set; }  // 1个字节

        private static byte size
        {
            get { return 1; }
        }

        private byte SignalBwPos
        {
            get { return 0; }
        }
 
        public const ushort Type = (ushort)0x134E;

        public byte[] BuildCmd()                // 形成完整的packet，包括SOF,LEN,CMD,DATA,FCS
        {
            byte[] cmdbuffer = new byte[size];  // 需要将SOF,LEN,CMD,FCS加进去
            cmdbuffer[0] = PayloadLength;
            cmdbuffer = MagneticOriginalPacket.BuildOriginalPacket(cmdbuffer, Type);
            return cmdbuffer;
        }

        public override string ToString()
        {
            string s = string.Format("{0,-25} {1,20} {2,25}", "(Field)", "(Hex)", "(Decimal)");
            s += string.Format("\n{0,-25}|{1,20:X4} {2,25:G}", "Type", Type, this.GetType().Name);
            s += string.Format("\n{0,-25}|{1,20:X2} {1,25:G}", "PayloadLength", PayloadLength);
            return s;
        }
    }
}